<?php

use think\facade\Route;

#base
Route::get('/', static function () {
    return json([
        'msg'  => 'welcome!',
        'code' => 0,
    ], 200);
});
Route::miss(static function () {
    return json([
        'msg'  => 'resource is not found！',
        'code' => -1,
    ], 404);
});

Route::post('login', 'admin/Admin/loginAdmin');
Route::get('info', 'admin/Admin/getAdminInfo');
Route::put('password', 'admin/Admin/putAdminPassword');
Route::put('loginOut', 'admin/Admin/putAdminLogout');
Route::group('user', function () {
    Route::get('list', 'admin/User/getUserList');
});

##rbac
Route::group('rbac', function () {
    #group
    Route::get('group/list', 'admin/Rbac/getRbacGroupList');
    Route::post('group', 'admin/Rbac/postRBACGroup');
    Route::put('group', 'admin/Rbac/putRbacGroup');
    Route::delete('group', 'admin/Rbac/deleteRBACGroup');

    #role
    Route::get('role/list', 'admin/Rbac/getRBACRoleList');
    Route::post('role', 'admin/Rbac/postRBACRole');
    Route::put('role', 'admin/Rbac/putRBACRole');
    Route::delete('role', 'admin/Rbac/deleteRBACRole');

    #group_role
    Route::post('group_role', 'admin/Rbac/postRBACGroupRole');
});

#backup
Route::group('system', function () {
    Route::get('backup/list', 'admin/System/getBackupList');
    Route::post('backup', 'admin/System/postBackup');
    Route::put('backup', 'admin/System/putBackup');
    Route::delete('backup', 'admin/System/deleteBackup');
});

#config
Route::group('config', function () {
    Route::get('list', 'admin/Config/getConfigList');
    Route::post('', 'admin/Config/postConfig');
    Route::put('', 'admin/Config/putConfig');
    Route::delete('', 'admin/Config/deleteConfig');
});

#media
Route::group('media', function () {
    Route::post('upload/file', 'admin/Media/uploadFile');
    //    Route::post('image', 'admin/Media/postImage');
    //    Route::delete('image', 'admin/Media/deleteImage');
    //
    //    Route::post('video', 'admin/Media/postVideo');
    //    Route::delete('video', 'admin/Media/deleteVideo');

    Route::get('list', 'admin/Media/getMediaList');
    Route::post('', 'admin/Media/postMedia');
    Route::put('', 'admin/Media/putMedia');
    Route::delete('', 'admin/Media/deleteMedia');

    Route::get('group/list', 'admin/Media/getMediaGroupList');
    Route::post('group', 'admin/Media/postMediaGroup');
    Route::put('group', 'admin/Media/putMediaGroup');
    Route::delete('group', 'admin/Media/deleteMediaGroup');
});

#article
Route::group('article', function () {
    Route::get('list', 'admin/Article/getArticleList');
    Route::post('', 'admin/Article/postArticle');
    Route::put('', 'admin/Article/putArticle');
    Route::delete('', 'admin/Article/deleteArticle');
});

#banner
Route::group('banner', function () {
    Route::get('list', 'admin/Banner/getBannerList');
    Route::post('', 'admin/Banner/postBanner');
    Route::put('', 'admin/Banner/putBanner');
    Route::delete('', 'admin/Banner/deleteBanner');
});

#product
Route::group('product', function () {
    Route::get('list', 'admin/Product/getProductList');
    Route::post('', 'admin/Product/postProduct');
    Route::put('', 'admin/Product/putProduct');
    Route::delete('', 'admin/Product/deleteProduct');

    Route::get('attr_group/list', 'admin/Product/getProductAttrGroupList');
    Route::post('attr_group', 'admin/Product/postProductAttrGroup');
    Route::put('attr_group', 'admin/Product/putProductAttrGroup');
    Route::delete('attr_group', 'admin/Product/deleteProductAttrGroup');

    Route::get('category/list', 'admin/Product/getProductCategoryList');
    Route::post('category', 'admin/Product/postProductCategory');
    Route::put('category', 'admin/Product/putProductCategory');
    Route::delete('category', 'admin/Product/deleteProductCategory');
});

#map
Route::group('map', function () {
    Route::get('list', 'admin/Map/getMapList');
    Route::post('', 'admin/Map/postMap');
    //    Route::put('', 'index/Map/putMap');
    //    Route::delete('', 'index/Map/deleteMap');
});


#order
Route::group('order', function () {
    Route::get('list', 'admin/Order/getOrderList');
    Route::put('fh', 'admin/Order/putOrderFh');
    Route::put('cancel', 'admin/Order/putOrderCancel');
    //    Route::put('refund/confirm', 'admin/Order/putOrderRefundConfirm');

    Route::get('refund/list', 'admin/Order/getRefundList');
    Route::put('refund/approve', 'admin/Order/putRefundApprove');
    Route::put('refund/refuse', 'admin/Order/putRefundRefuse');
    Route::put('refund/shouHuo', 'admin/Order/putRefundShouHuo');
    Route::put('refund/yanHuo', 'admin/Order/putRefundYanhuo');

});


Route::group('coupon', function () {
    Route::get('list', 'admin/Coupon/getCouponList');
    Route::post('product/list', 'admin/Coupon/getProductList');
    Route::post('', 'admin/Coupon/postCoupon');
    Route::put('', 'admin/Coupon/putCoupon');
    Route::delete('', 'admin/Coupon/deleteCoupon');

    Route::get('user/list', 'admin/Coupon/getUserCouponList');
    Route::post('user', 'admin/Coupon/postUserCoupon');
    Route::put('user', 'admin/Coupon/putUserCoupon');
    Route::delete('user', 'admin/Coupon/deleteUserCoupon');

    Route::get('user/record/list', 'admin/Coupon/getUserCouponRecordList');
    Route::post('user/record', 'admin/Coupon/postUserCouponRecord');
    Route::put('user/record', 'admin/Coupon/putUserCouponRecord');
    Route::delete('user/record', 'admin/Coupon/deleteUserCouponRecord');

    Route::get('issue/list', 'admin/Coupon/getCouponIssueList');
    Route::post('issue', 'admin/Coupon/postCouponIssue');
    Route::put('issue', 'admin/Coupon/putCouponIssue');
    Route::delete('issue', 'admin/Coupon/deleteCouponIssue');

    Route::post('give/admin', 'admin/Coupon/postCouponAdminGive');
});

#package
Route::group('package', function () {
    Route::get('company/list', 'admin/Package/getPackageCompanyList');
});

Route::group('YYYYY', function () {
    Route::get('xxxxx/list', 'admin/YYYYY/getXXXXXList');
    Route::post('xxxxx', 'admin/YYYYY/postXXXXX');
    Route::put('xxxxx', 'admin/YYYYY/putXXXXX');
    Route::delete('xxxxx', 'admin/YYYYY/deleteXXXXX');
});


//->allowCrossDomain([
//'Access-Control-Allow-Origin'        => '*',
//'Access-Control-Allow-Credentials'   => 'true'
//]);

